package com.system.connect.springboot_flowers.dto;

import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

@Data
public class OrderCreateDTO {
    
    @NotNull(message = "收货地址ID不能为空")
    private Long addressId;
    
    private String deliveryTime;
    
    private String deliveryType;
    
    @NotNull(message = "运费不能为空")
    private BigDecimal freightAmount;
    
    @Valid
    private InvoiceDTO invoice;
    
    @NotEmpty(message = "订单商品不能为空")
    @Valid
    private List<OrderItemDTO> items;
    
    private String orderType;
    
    @NotNull(message = "支付方式不能为空")
    private Integer paymentType;
    
    @NotNull(message = "订单总金额不能为空")
    private BigDecimal totalAmount;
    
    private String note;

    @Data
    public static class InvoiceDTO {
        private String type;
    }
    
    @Data
    public static class OrderItemDTO {
        @NotNull(message = "商品ID不能为空")
        private Long itemId;
        
        @NotNull(message = "商品名称不能为空")
        private String name;
        
        private String image;
        
        @NotNull(message = "商品单价不能为空")
        private BigDecimal price;
        
        @NotNull(message = "商品数量不能为空")
        private Integer quantity;
        
        private String spec;
    }
}
